package com.godofgamblers.hotelmanagementsystem.service.imp;

import com.godofgamblers.hotelmanagementsystem.mapper.CartMapper;
import com.godofgamblers.hotelmanagementsystem.pojo.Cart;
import com.godofgamblers.hotelmanagementsystem.pojo.User;
import com.godofgamblers.hotelmanagementsystem.pojo.User_Level;
import com.godofgamblers.hotelmanagementsystem.service.CartService;
import lombok.Data;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author wzx
 * @date 2019/10/14 - 10:35
 */
@Service
@Transactional
@Data
public class CartServiceImp implements CartService {
    @Resource
    private CartMapper cartMapper;
    @Override
    //用户登陆成功后点击自己的购物车查询属于自己的购物车（参数：用户id）返回一个集合装有多个项目
    public List<Cart> findMyCart(User user) {
        return cartMapper.findMyCart(user);
    }

    @Override
    //选择一类房间加入购物车（参数：用户id,房间类型id，计划入住时间，计划退房时间）
    public void addCart(Cart cart) {
        cartMapper.addCart(cart);
    }

    @Override
    //根据用户的id去查询该用户的会员级别以及享受的折扣
    public User_Level findUserLevel(User user) {
        return cartMapper.findUserLevel(user);
    }

    @Override
    //在购物车中点击移除按钮，删除某一行数据(参数：删除那一行的id(cart_id))
    public void deleteCart(Integer cart_id) {
        cartMapper.deleteCart(cart_id);
    }

    @Override
    //在购物车中修改入住和离店时间
    public void updateCart(Cart cart) {
        cartMapper.updateCart(cart);
    }

    @Override
    public Cart findRoomTypeID(Map map) {
        return cartMapper.findRoomTypeID(map);
    }

    @Override
    public void deleteSomeCart(Integer cart_id) {
        cartMapper.deleteSomeCart(cart_id);
    }
}
